package com.ibangnuo.manage.controller.order;

import com.ibangnuo.api.order.SuccessionSettlementControllerApi;
import com.ibangnuo.framework.domain.request.order.SuccessionSettlementQueryRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.order.SuccessionSettlementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wwy
 * @Date: 2020-01-02 17:21
 */
@RestController
@RequestMapping("/successionSettlement")
public class SuccessionSettlementController implements SuccessionSettlementControllerApi {
    @Autowired
    private SuccessionSettlementService successionSettlementService;

    /**
     * 分页条件查询
     * @param page
     * @param size
     * @param successionSettlementQueryRequest
     * @return
     */
    @PostMapping("/list/{page}/{size}")
    @Override
    public QueryResponseResult findList(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody SuccessionSettlementQueryRequest successionSettlementQueryRequest) {
        return successionSettlementService.findList(page,size,successionSettlementQueryRequest);
    }

    /**
     * 条件查询进入redis
     * @param successionSettlementQueryRequest
     * @return
     */
    @PostMapping("/querySuccSet")
    @Override
    public ObjectResult querySuccSet(@RequestBody SuccessionSettlementQueryRequest successionSettlementQueryRequest) {
        return successionSettlementService.querySuccSet(successionSettlementQueryRequest);
    }

    /**
     * 依据redisId查询出缓存数据进行添加
     * @param redisId
     * @return
     */
    @GetMapping("/add/{redisId}")
    @Override
    public ResponseResult add(@PathVariable("redisId") String redisId) {
        return successionSettlementService.add(redisId);
    }

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @GetMapping("/findById/{id}")
    @Override
    public ObjectResult findById(@PathVariable("id") String id) {
        return successionSettlementService.findById(id);
    }
}
